package com.gitee.wsl.compose.use.coroutines

import androidx.compose.runtime.Composable
import kotlinx.coroutines.delay
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds

/**
 * Description: 定时一段时间后执行的任务
 * @author Junerver
 * date: 2024/2/1-15:08
 * Email: junerver@gmail.com
 * Version: v1.0
 */
@Composable
fun useTimeout(delay: Duration = 1.seconds, fn: () -> Unit) {
    useEffect {
        delay(delay)
        fn()
    }
}